package com.pucong.gitee.database.backup.common.entity.database.dto;

import com.pucong.gitee.database.backup.common.selfenum.DatabaseTypeEnum;
import com.pucong.gitee.database.backup.common.selfenum.DatabaseVersionEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

@Data
@ApiModel("测试连接dto")
public class AutoDataSourceTestConnectDto implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("主键")
    private String uuid;

    @NotBlank
    @ApiModelProperty("连接名称")
    private String connectName;

    @NotBlank
    @ApiModelProperty("IP地址")
    private String host;

    @NotBlank
    @ApiModelProperty(value = "端口号",example = "1")
    private Integer port;

    @NotBlank
    @ApiModelProperty("数据库类型")
    private DatabaseTypeEnum databaseType;

    @ApiModelProperty("数据库版本")
    private DatabaseVersionEnum databaseVersion;

    @NotBlank
    @ApiModelProperty("数据库名称")
    private String databaseName;

    @ApiModelProperty("模式名称")
    private String schemaName;

    @NotBlank
    @ApiModelProperty("用户名")
    private String username;

    @NotBlank
    @ApiModelProperty("密码")
    private String password;

    public void setDatabaseType(int value) {
        this.databaseType = DatabaseTypeEnum.findEnumByValue(value);
    }

    public void setDatabaseVersion(int value) {
        this.databaseVersion = DatabaseVersionEnum.findEnumByValue(value);
    }
}
